<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ page import="com.lp.cfg.ProConfig"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<!DOCTYPE html>
<html>
<head>
	<title><%=ProConfig.PROJECT_NAME %></title>
	<%@ include file="/WEB-INF/wechat/iot/common/resource_lib.jsp"%>
	
</head>
<body>
	<div class="t-c title-info" >
		<span>联系人微信绑定</span>
	</div>
	<div style="height: 50px;"></div>
	<div class="container" >
		<div class="weui-cells weui-cells_form">
				<div class="weui-cell">
					<div class="weui-cell__hd">
						<label class="weui-label">名称：</label>
					</div>
					<div class="weui-cell__bd">
						<span class="discolor">${info.data.name}</span>
					</div>
				</div>
				
				<div class="weui-cell">
					<div class="weui-cell__hd">
						<label class="weui-label">邮箱：</label>
					</div>
					<div class="weui-cell__bd">
						<span class="discolor">${info.data.email}</span>
					</div>
				</div>

				<div class="weui-cell">
					<div class="weui-cell__hd">
						<label class="weui-label">手机号:</label>
					</div>
					<div class="weui-cell__bd">
						<span class="discolor">${info.data.phone}</span>
					</div>
				</div>
				
				<div class="weui-cell">
					<div class="weui-cell__hd">
						<label class="weui-label">微信头像:</label>
					</div>
					<div class="weui-cell__bd">
						<img src="${user.wx_img_url }" style="width: 80px;border-radius: 50%;" > 
					</div>
				</div>

			</div>
			<div class="width90 m-auto" style="padding: 10px 0;">
				<a class="weui-btn" style="background: #3499da;" onclick="saveBtn()"  id="saveBtn">绑定</a>			
			</div>
	</div>
	<script src="http://res2.wx.qq.com/open/js/jweixin-1.4.0.js"></script>
	<script src="<%=basePath%>/lib/weixinLib/WeixinApi.js"></script>
</body>
	<script type="text/javascript">
		function before(data){
			return data ;
		}
		
		function saveBtn(){
			var data = {
				id: '${info.data.id}' ,
				wx_key: '${user.wx_open_id}',
				wx_img: '${user.wx_img_url}'
			};
			if( validater.empty( data.wx_key ) ){
				tip("请在微信浏览器中打开",'w');
				return ;
			}
			commonAjax('PUT',localUrl+"/contact/user/info.json", data,function(data){
				if(isOK(data)){
					tip("绑定成功");
					setTimeout(function() {
						WeixinJSBridge.call('closeWindow');
					}, 500);
				}
			});
		}
		
	</script>
</html>